package com.yijian.oj.judge.manager;

import com.yijian.oj.judge.codesandbox.model.JudgeContext;
import com.yijian.oj.judge.codesandbox.strategy.JudgeStrategy;
import com.yijian.oj.judge.codesandbox.strategy.impl.DefaultJudgeStrategy;
import com.yijian.oj.judge.codesandbox.strategy.impl.JavaLanguageJudgeStrategy;
import com.yijian.oj.judge.codesandbox.model.JudgeInfo;
import com.yijian.oj.model.entity.QuestionSubmit;
import org.springframework.stereotype.Service;

/**
 * 判题策略（简化开发）
 * @author ItJianGe
 * @data 2024/3/25 12:25
 */
@Service
public class JudgeManager {

    public JudgeInfo doJudge(JudgeContext judgeContext) {
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy = new DefaultJudgeStrategy();
        if ("java".equals(language)) {
            judgeStrategy = new JavaLanguageJudgeStrategy();
        }
        return judgeStrategy.doJudge(judgeContext);
    }
}
